/*
 * KiDebugPort.h
 *
 *  Created on: 2013-10-25
 *      Author: WinDDK
 */

#ifndef KIDEBUGPORT_H_
#define KIDEBUGPORT_H_

#include "Utility.h"

class KiDebugPort
{
private:
    static const ULONG MAX_IDT_ENTRIES = 255;
    ULONG mNewImageBase;
    ULONG mOldImageBase;
public:
    KiDebugPort(ULONG oldImageBase, ULONG newImageBase);
    virtual ~KiDebugPort();

    ULONG Char2Hex(CHAR c);
    BOOLEAN MatchPattern(PUCHAR Address, PCHAR Pattern);
    BOOLEAN ReplaceDebugPortCode(PVOID CodeAddress, ULONG CodeLength);
    BOOLEAN FixDebugPortCode();
    BOOLEAN FixCodeReferences();
    BOOLEAN FixInterruptTable();
    BOOLEAN FixInterruptTable(ULONG oldImageBase, ULONG newImageBase);
    IDTENTRY* GetSystemInterruptTable();
    BOOLEAN SetSystemInterruptTable(IDTENTRY* NewEntry);
};

#endif /* KIDEBUGPORT_H_ */
